// 题意：字符集为{'a', 'b'}，给定一个串S，找任意一个最短的串T使得T不是S的子串。
//
// 题解：这题hash能过。用sa可以有O(log(log(n)) * n)的做法，就是用sa统计长度
//       为L的不相同串的个数，不需要了...
//
// run: $exec < input
#include <iostream>
#include <cmath>

int const maxn = 1000007;
bool has[maxn];
bool da[maxn];
int n;
std::string s;

bool judge(int l)
{
	int now = 0, tot = 1;
	for (int i = 0; i < (1<<l); i++) has[i] = false;
	for (int i = 0; i < l; i++) now = now * 2 + da[i];
	has[now] = true;
	for (int i = l; i < n; i++) {
		now -= da[i - l] * (1<<(l-1));
		now = now * 2 + da[i];
		if (!has[now]) {
			tot++;
			has[now] = true;
		}
	}
	return (tot < (1<<l));
}

void print(int x, int l)
{
	std::string out;
	for (int i = 0; i < l; i++, x /= 2)
		out = ((x&1) ? 'b' : 'a') + out;
	std::cout << out << '\n';
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> s;
	for (int i = 0; i < n; i++) da[i] = s[i] == 'b';
	int len = std::log(n)/std::log(2) + 1;

	int l = 1, r = len;
	while (l + 1 <= r) {
		int mid = (l + r) / 2;
		if (judge(mid)) r = mid;
		else			l = mid + 1;
	}
	if (judge(l)) r = l;
	std::cout << r << '\n';
	for (int i = 0; i < (1<<len); i++)
		if (!has[i]) { print(i, r); break; }
}

